function OtherMail() {
};

OtherMail.instance = function() {
  var popupBox = new PopupBox(), _self = this;
  
  var model = Model.instance('{{$smarty.const.MODEL_NAME_MAIL|escape:javascript}}', '{{$smarty.const.MODEL_TITLE_MAIL|escape:javascript}}', '{{$smarty.const.MODEL_TYPE_OTHER|escape:javascript}}');
  
  //Create model here...
  var state1 = State.instance(model, 0, 'not activate');
  var state2 = State.instance(model, 1, 'receive parcel');
  var state3 = State.instance(model, 2, 'parcel received');
  var transition1 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER_ASSISTANT|escape:javascript}}', DlmanageUtils.none);
  
  var transition2 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_MANAGER|escape:javascript}}', DlmanageUtils.none);

  var transition3 = Transition.instance('received', state2, state3, '{{$smarty.const.USER_TYPE_ADMIN|escape:javascript}}', DlmanageUtils.none);

  transition1.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    produce.receivedDate = date;
                                                                                    options._object = DlmanageUtils.receive(produce.v2_produces, (options && options.models) ? options.models : {}, user, date, options);
                                                                                    var str = '';
                                                                                    for (var i = 0, il = produce.v2_produces.length; i < il; i++) {
                                                                                      var p = produce.v2_produces[i];
                                                                                      if (!p._received) {
                                                                                        str += p.title + ', ';
                                                                                      }
                                                                                    }
                                                                                    options.extra = 'LOST: ' + str.substring(0, str.length - 2);
                                                                                    DlmanageUtils.operate(transition1, pos, callbackFunc, produce, user, date, options);
                                                                                  };
  
  transition2.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                      options = {};
                                                                                    }
                                                                                    var previous = MiscUtils.clone(produce);
                                                                                    options.previous = previous;
                                                                                    produce.receivedDate = date;
                                                                                    options._object = DlmanageUtils.receive(produce.v2_produces, (options && options.models) ? options.models : {}, user, date, options);
                                                                                    var str = '';
                                                                                    for (var i = 0, il = produce.v2_produces.length; i < il; i++) {
                                                                                      var p = produce.v2_produces[i];
                                                                                      if (!p._received) {
                                                                                        str += p.title + ', ';
                                                                                      }
                                                                                    }
                                                                                    options.extra = 'LOST: ' + str.substring(0, str.length - 2);
                                                                                    DlmanageUtils.operate(transition2, pos, callbackFunc, produce, user, date, options);
                                                                                  };
transition3.operate = function(pos, callbackFunc, produce, user, date, options) { if (!options) {
                                                                                    options = {};
                                                                                  }
                                                                                  var previous = MiscUtils.clone(produce);
                                                                                  options.previous = previous;
                                                                                  produce.receivedDate = date;
                                                                                  options._object = DlmanageUtils.receive(produce.v2_produces, (options && options.models) ? options.models : {}, user, date, options);
                                                                                  var str = '';
                                                                                  for (var i = 0, il = produce.v2_produces.length; i < il; i++) {
                                                                                    var p = produce.v2_produces[i];
                                                                                    if (!p._received) {
                                                                                      str += p.title + ', ';
                                                                                    }
                                                                                  }
                                                                                  options.extra = 'LOST: ' + str.substring(0, str.length - 2);
                                                                                  DlmanageUtils.operate(transition3, pos, callbackFunc, produce, user, date, options);
                                                                                };
  model.states = [ state1, state2, state3 ];
  model.transitions = [ transition1, transition2, transition3 ];
  return model;
};
